package jay.home.bet.web.struts;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import jay.home.bet.domain.Event;
import jay.home.bet.misc.Util;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

public class UpdateEventAction extends BaseAction
{

	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception
	{
		request.getParameterMap();

		Event event = new Event();
		String compId = request.getParameter("compId");
		event.getComp().setId(compId);

		System.out.println("compId =   " + compId);

		event.getDuying().setWin(
				Util.toDouble(request.getParameter("duying.win")));
		event.getDuying().setLose(
				Util.toDouble(request.getParameter("duying.lose")));
		event.getDuying().setDraw(
				Util.toDouble(request.getParameter("duying.draw")));

		event.getDanshuang().setOdd(
				Util.toDouble(request.getParameter("danshuang.odd")));
		event.getDanshuang().setEven(
				Util.toDouble(request.getParameter("danshuang.even")));

		event.getBanquanchang().setHr(
				Util.toDouble(request.getParameter("banquanchang.hr")));
		event.getBanquanchang().setHh(
				Util.toDouble(request.getParameter("banquanchang.hh")));
		event.getBanquanchang().setHd(
				Util.toDouble(request.getParameter("banquanchang.hd")));
		event.getBanquanchang().setRr(
				Util.toDouble(request.getParameter("banquanchang.rr")));
		event.getBanquanchang().setRh(
				Util.toDouble(request.getParameter("banquanchang.rh")));
		event.getBanquanchang().setRd(
				Util.toDouble(request.getParameter("banquanchang.rd")));
		event.getBanquanchang().setDd(
				Util.toDouble(request.getParameter("banquanchang.dd")));
		event.getBanquanchang().setDh(
				Util.toDouble(request.getParameter("banquanchang.dh")));
		event.getBanquanchang().setDr(
				Util.toDouble(request.getParameter("banquanchang.dr")));

		event.getBodan().setS00(
				Util.toDouble(request.getParameter("bodan.s00")));
		event.getBodan().setS01(
				Util.toDouble(request.getParameter("bodan.s01")));
		event.getBodan().setS02(
				Util.toDouble(request.getParameter("bodan.s02")));
		event.getBodan().setS03(
				Util.toDouble(request.getParameter("bodan.s03")));
		event.getBodan().setS04(
				Util.toDouble(request.getParameter("bodan.s04")));
		event.getBodan().setS10(
				Util.toDouble(request.getParameter("bodan.s10")));
		event.getBodan().setS11(
				Util.toDouble(request.getParameter("bodan.s11")));
		event.getBodan().setS12(
				Util.toDouble(request.getParameter("bodan.s12")));
		event.getBodan().setS13(
				Util.toDouble(request.getParameter("bodan.s13")));
		event.getBodan().setS14(
				Util.toDouble(request.getParameter("bodan.s14")));
		event.getBodan().setS20(
				Util.toDouble(request.getParameter("bodan.s20")));
		event.getBodan().setS21(
				Util.toDouble(request.getParameter("bodan.s21")));
		event.getBodan().setS22(
				Util.toDouble(request.getParameter("bodan.s22")));
		event.getBodan().setS23(
				Util.toDouble(request.getParameter("bodan.s23")));
		event.getBodan().setS24(
				Util.toDouble(request.getParameter("bodan.s24")));
		event.getBodan().setS30(
				Util.toDouble(request.getParameter("bodan.s30")));
		event.getBodan().setS31(
				Util.toDouble(request.getParameter("bodan.s31")));
		event.getBodan().setS32(
				Util.toDouble(request.getParameter("bodan.s32")));
		event.getBodan().setS33(
				Util.toDouble(request.getParameter("bodan.s33")));
		event.getBodan().setS34(
				Util.toDouble(request.getParameter("bodan.s34")));
		event.getBodan().setS40(
				Util.toDouble(request.getParameter("bodan.s40")));
		event.getBodan().setS41(
				Util.toDouble(request.getParameter("bodan.s41")));
		event.getBodan().setS42(
				Util.toDouble(request.getParameter("bodan.s42")));
		event.getBodan().setS43(
				Util.toDouble(request.getParameter("bodan.s43")));
		event.getBodan().setS44(
				Util.toDouble(request.getParameter("bodan.s44")));
		event.getBodan().setSxx(
				Util.toDouble(request.getParameter("bodan.sxx")));

		event.getRuqiushu().setS01(
				Util.toDouble(request.getParameter("ruqiushu.s01")));
		event.getRuqiushu().setS23(
				Util.toDouble(request.getParameter("ruqiushu.s23")));
		event.getRuqiushu().setS46(
				Util.toDouble(request.getParameter("ruqiushu.s46")));
		event.getRuqiushu().setSup7(
				Util.toDouble(request.getParameter("ruqiushu.sup7")));

		event.getDaxiaoHalf().setHome(
				Util.toDouble(request.getParameter("daxiaoHalf.home")));
		event.getDaxiaoHalf().setRoad(
				Util.toDouble(request.getParameter("daxiaoHalf.road")));
		event.getDaxiaoHalf().setPankou(
				request.getParameter("daxiaoHalf.pankou"));

		event.getRangqiuHalf().setHome(
				Util.toDouble(request.getParameter("rangqiuHalf.home")));
		event.getRangqiuHalf().setRoad(
				Util.toDouble(request.getParameter("rangqiuHalf.road")));
		event.getRangqiuHalf().setPankou(
				request.getParameter("rangqiuHalf.pankou"));
		event.getRangqiuHalf().setWho2who(
				request.getParameter("rangqiuHalf.who2who"));

		event.getDuyingHalf().setWin(
				Util.toDouble(request.getParameter("duyingHalf.win")));
		event.getDuyingHalf().setLose(
				Util.toDouble(request.getParameter("duyingHalf.lose")));
		event.getDuyingHalf().setDraw(
				Util.toDouble(request.getParameter("duyingHalf.draw")));

		getOddsService().updateEventsByComp(event);

		String id = request.getParameter("id");
		event = getOddsService().getEvent(id);

		System.out.println("EventId =   " + id);

		event.setId(id);

		event.getDaxiao().setHome(
				Util.toDouble(request.getParameter("daxiao.home")));
		event.getDaxiao().setRoad(
				Util.toDouble(request.getParameter("daxiao.road")));
		event.getDaxiao().setPankou(request.getParameter("daxiao.pankou"));

		event.getRangqiu().setHome(
				Util.toDouble(request.getParameter("rangqiu.home")));
		event.getRangqiu().setRoad(
				Util.toDouble(request.getParameter("rangqiu.road")));
		event.getRangqiu().setPankou(request.getParameter("rangqiu.pankou"));
		event.getRangqiu().setWho2who(request.getParameter("rangqiu.who2who"));

		getOddsService().updateEvent(event);
		return mapping.findForward("SUCCESS");
	}
}
